/*
 * WebServer_GUIView.java
 */
package webserver_gui;

import Controller.ClientXMLServerInfo;
import Controller.OurListener;
import Controller.ServerInfo;
import Controller.VirtualDirectory;
import Controller.XMLVirtualDirectory;
import Supporter.OurDialog;
import Supporter.OurLogger;
import java.awt.Color;
import java.io.IOException;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import javax.imageio.ImageIO;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import org.jdom.JDOMException;

/**
 * Server GUI's main frame.
 */
public class WebServer_GUIView extends FrameView {

    DefaultTableModel dtmVirtualFolder;
    String sOldCellValue;
    TimerLoad tAutoLoad;
    boolean bEditName = false;
    int iTimeAutoLoad = 10;//s'

    public WebServer_GUIView(SingleFrameApplication app) throws IOException {
        super(app);

        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });

        //////////////////////........Load Default...................
//        getFrame().addWindowStateListener(new WindowAdapter() {
//
//            @Override
//            public void windowStateChanged(WindowEvent ex) {
//                if (ex.getNewState() == JFrame.ICONIFIED) {
//                    ((WebServer_GUIApp) getApplication()).toggleMainFrame();
//                }
//            }
//        });

        Load();
        LoadConfig();
        tAutoLoad = new TimerLoad(this, iTimeAutoLoad);//số giây hiển thị trạng thái của thư mục ảo

        try {
            VirtualDirectory test = VirtualDirectory.getRealPath("a/bb/ccc/dddda/eeeee");
            int i = 0;
        } catch (Exception ex) {
            OurLogger.logError(this, "init()", ex, Level.SEVERE);
        }

        try {
            BufferedImage main = ImageIO.read(new File("server icon.jpg"));
            BufferedImage makeFolder = ImageIO.read(new File("MakeFolder icon.png"));
            BufferedImage changePort = ImageIO.read(new File("Port icon.png"));
            getFrame().setIconImage(main);

            jInternalFrame1.setFrameIcon(new ImageIcon(makeFolder));
            jInternalFrame2.setFrameIcon(new ImageIcon(main));
            jInternalFrame2.setFrameIcon(new ImageIcon(changePort));
        } catch (Exception ex) {
        }
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = WebServer_GUIApp.getApplication().getMainFrame();
            aboutBox = new WebServer_GUIAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        WebServer_GUIApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        lbLogo = new javax.swing.JLabel();
        jSplitPane1 = new javax.swing.JSplitPane();
        jPanel2 = new javax.swing.JPanel();
        jInternalFrame1 = new javax.swing.JInternalFrame();
        btPatchFolder = new javax.swing.JButton();
        lbTenDinhDanh = new javax.swing.JLabel();
        btAddVirtualFolder = new javax.swing.JButton();
        tbVirtualName = new javax.swing.JTextField();
        jInternalFrame2 = new javax.swing.JInternalFrame();
        btChangConfig = new javax.swing.JButton();
        lbTenDinhDanh2 = new javax.swing.JLabel();
        tbPort = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblViewVirtualFolders = new javax.swing.JTable();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        miAbout = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(webserver_gui.WebServer_GUIApp.class).getContext().getResourceMap(WebServer_GUIView.class);
        mainPanel.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        mainPanel.setName("mainPanel"); // NOI18N

        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel1.setName("jPanel1"); // NOI18N

        lbLogo.setFont(resourceMap.getFont("lbLogo.font")); // NOI18N
        lbLogo.setForeground(resourceMap.getColor("lbLogo.foreground")); // NOI18N
        lbLogo.setText(resourceMap.getString("lbLogo.text")); // NOI18N
        lbLogo.setName("lbLogo"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(230, 230, 230)
                .addComponent(lbLogo)
                .addContainerGap(432, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lbLogo)
        );

        jSplitPane1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jSplitPane1.setName("jSplitPane1"); // NOI18N

        jPanel2.setBackground(resourceMap.getColor("jPanel2.background")); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jInternalFrame1.setBackground(resourceMap.getColor("jInternalFrame1.background")); // NOI18N
        jInternalFrame1.setTitle(resourceMap.getString("jInternalFrame1.title")); // NOI18N
        jInternalFrame1.setName("jInternalFrame1"); // NOI18N
        jInternalFrame1.setVisible(true);

        btPatchFolder.setFont(resourceMap.getFont("btPatchFolder.font")); // NOI18N
        btPatchFolder.setForeground(resourceMap.getColor("btPatchFolder.foreground")); // NOI18N
        btPatchFolder.setText(resourceMap.getString("btPatchFolder.text")); // NOI18N
        btPatchFolder.setToolTipText(resourceMap.getString("btPatchFolder.toolTipText")); // NOI18N
        btPatchFolder.setName("btPatchFolder"); // NOI18N
        btPatchFolder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPatchFolderActionPerformed(evt);
            }
        });

        lbTenDinhDanh.setFont(resourceMap.getFont("lbTenDinhDanh.font")); // NOI18N
        lbTenDinhDanh.setText(resourceMap.getString("lbTenDinhDanh.text")); // NOI18N
        lbTenDinhDanh.setName("lbTenDinhDanh"); // NOI18N

        btAddVirtualFolder.setFont(resourceMap.getFont("btAddVirtualFolder.font")); // NOI18N
        btAddVirtualFolder.setForeground(resourceMap.getColor("btAddVirtualFolder.foreground")); // NOI18N
        btAddVirtualFolder.setText(resourceMap.getString("btAddVirtualFolder.text")); // NOI18N
        btAddVirtualFolder.setName("btAddVirtualFolder"); // NOI18N
        btAddVirtualFolder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddVirtualFolderActionPerformed(evt);
            }
        });

        tbVirtualName.setFont(resourceMap.getFont("tbVirtualName.font")); // NOI18N
        tbVirtualName.setForeground(resourceMap.getColor("tbVirtualName.foreground")); // NOI18N
        tbVirtualName.setText(resourceMap.getString("tbVirtualName.text")); // NOI18N
        tbVirtualName.setToolTipText(resourceMap.getString("tbVirtualName.toolTipText")); // NOI18N
        tbVirtualName.setName("tbVirtualName"); // NOI18N

        javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
        jInternalFrame1Layout.setHorizontalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btPatchFolder)
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addComponent(lbTenDinhDanh)
                        .addGap(27, 27, 27))
                    .addComponent(tbVirtualName, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addGap(45, 45, 45)
                        .addComponent(btAddVirtualFolder, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jInternalFrame1Layout.setVerticalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(btPatchFolder)
                .addGap(18, 18, 18)
                .addComponent(lbTenDinhDanh)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbVirtualName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btAddVirtualFolder)
                .addContainerGap(128, Short.MAX_VALUE))
        );

        jInternalFrame2.setBackground(resourceMap.getColor("jInternalFrame2.background")); // NOI18N
        jInternalFrame2.setTitle(resourceMap.getString("jInternalFrame2.title")); // NOI18N
        jInternalFrame2.setName("jInternalFrame2"); // NOI18N
        jInternalFrame2.setVisible(true);

        btChangConfig.setFont(resourceMap.getFont("btChangConfig.font")); // NOI18N
        btChangConfig.setForeground(resourceMap.getColor("btChangConfig.foreground")); // NOI18N
        btChangConfig.setText(resourceMap.getString("btChangConfig.text")); // NOI18N
        btChangConfig.setName("btChangConfig"); // NOI18N
        btChangConfig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btChangConfigActionPerformed(evt);
            }
        });

        lbTenDinhDanh2.setFont(resourceMap.getFont("lbTenDinhDanh2.font")); // NOI18N
        lbTenDinhDanh2.setText(resourceMap.getString("lbTenDinhDanh2.text")); // NOI18N
        lbTenDinhDanh2.setName("lbTenDinhDanh2"); // NOI18N

        tbPort.setFont(resourceMap.getFont("tbPort.font")); // NOI18N
        tbPort.setForeground(resourceMap.getColor("tbPort.foreground")); // NOI18N
        tbPort.setToolTipText(resourceMap.getString("tbPort.toolTipText")); // NOI18N
        tbPort.setName("tbPort"); // NOI18N

        javax.swing.GroupLayout jInternalFrame2Layout = new javax.swing.GroupLayout(jInternalFrame2.getContentPane());
        jInternalFrame2.getContentPane().setLayout(jInternalFrame2Layout);
        jInternalFrame2Layout.setHorizontalGroup(
            jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrame2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbTenDinhDanh2)
                .addGap(18, 18, 18)
                .addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btChangConfig, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbPort, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE))
                .addContainerGap())
        );
        jInternalFrame2Layout.setVerticalGroup(
            jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrame2Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tbPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbTenDinhDanh2))
                .addGap(18, 18, 18)
                .addComponent(btChangConfig)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jInternalFrame2, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jInternalFrame1, javax.swing.GroupLayout.Alignment.LEADING))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jInternalFrame2)
                .addContainerGap())
        );

        jSplitPane1.setLeftComponent(jPanel2);

        jPanel4.setBackground(resourceMap.getColor("jPanel4.background")); // NOI18N
        jPanel4.setName("jPanel4"); // NOI18N

        jPanel5.setBackground(resourceMap.getColor("jPanel5.background")); // NOI18N
        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel5.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jPanel5.border.titleFont"), resourceMap.getColor("jPanel5.border.titleColor"))); // NOI18N
        jPanel5.setName("jPanel5"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        tblViewVirtualFolders.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, resourceMap.getColor("tblViewVirtualFolders.border.matteColor"))); // NOI18N
        tblViewVirtualFolders.setFont(resourceMap.getFont("tblViewVirtualFolders.font")); // NOI18N
        tblViewVirtualFolders.setForeground(resourceMap.getColor("tblViewVirtualFolders.foreground")); // NOI18N
        tblViewVirtualFolders.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "1", "2", "3"
            }
        ));
        tblViewVirtualFolders.setToolTipText(resourceMap.getString("tblViewVirtualFolders.toolTipText")); // NOI18N
        tblViewVirtualFolders.setGridColor(resourceMap.getColor("tblViewVirtualFolders.gridColor")); // NOI18N
        tblViewVirtualFolders.setName("tblViewVirtualFolders"); // NOI18N
        tblViewVirtualFolders.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblViewVirtualFoldersMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                tblViewVirtualFoldersMouseExited(evt);
            }
        });
        tblViewVirtualFolders.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                tblViewVirtualFoldersPropertyChange(evt);
            }
        });
        tblViewVirtualFolders.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
                tblViewVirtualFoldersAncestorRemoved(evt);
            }
        });
        tblViewVirtualFolders.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tblViewVirtualFoldersKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tblViewVirtualFoldersKeyReleased(evt);
            }
        });
        jScrollPane3.setViewportView(tblViewVirtualFolders);
        tblViewVirtualFolders.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tblViewVirtualFolders.columnModel.title0")); // NOI18N
        tblViewVirtualFolders.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tblViewVirtualFolders.columnModel.title2")); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel5.getAccessibleContext().setAccessibleName(resourceMap.getString("jPanel5.AccessibleContext.accessibleName")); // NOI18N

        jSplitPane1.setRightComponent(jPanel4);

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 865, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
                .addContainerGap())
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem3.setText(resourceMap.getString("jMenuItem3.text")); // NOI18N
        jMenuItem3.setName("jMenuItem3"); // NOI18N
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        fileMenu.add(jMenuItem3);

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        fileMenu.add(jMenuItem1);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        helpMenu.add(jMenuItem2);

        miAbout.setText(resourceMap.getString("miAbout.text")); // NOI18N
        miAbout.setName("miAbout"); // NOI18N
        miAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miAboutActionPerformed(evt);
            }
        });
        helpMenu.add(miAbout);

        menuBar.add(helpMenu);

        statusPanel.setBackground(resourceMap.getColor("statusPanel.background")); // NOI18N
        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 715, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    public void Load() {
        if (bEditName == false) {
            try {
                List<VirtualDirectory> listVirFolder = XMLVirtualDirectory.GetALL();
                if (listVirFolder == null) {
                    OurDialog.showErrorDialog("Không thể kết nối cơ sở dữ liệu\r\nBạn hãy khởi động lại chương trình. ");
                    System.exit(0);
                }
                Vector<String> rowHeader = new Vector();
                rowHeader.addElement("Tên thư mục ảo");
                rowHeader.addElement("Đường dẫn");
                rowHeader.addElement("Tình trạng");

                ////////tao TableModel chua du lieu cho Jtable
                dtmVirtualFolder = new DefaultTableModel(rowHeader, 0) {

                    public boolean isCellEditable(int rowIndex, int mColIndex) {
                        if (mColIndex == 0) {
                            return true;
                        }
                        return false;
                    }
                };//Readonly JTable

                for (int i = 0; i < listVirFolder.size(); i++) {
                    VirtualDirectory virFolder = new VirtualDirectory(listVirFolder.get(i).getName(), listVirFolder.get(i).getPatch());
                    Vector rowData = new Vector();
                    rowData.add(virFolder.getName());
                    rowData.add(virFolder.getPatch());
                    rowData.add((virFolder.getExist() == true) ? "    Tốt" : "   Hỏng");

                    dtmVirtualFolder.addRow(rowData);
                }
                tblViewVirtualFolders.setModel(dtmVirtualFolder);
                tblViewVirtualFolders.setToolTipText("__ Muốn chỉnh sửa: Double click vào ô cột \"Tên thư mục ảo\" và \"Đường dẫn\".\r\n"
                        + "__ Muốn xóa: Chọn những dòng cần xóa và nhấn phím Delete");
                System.out.println("-Load ok");
            } catch (Exception ex) {
                System.out.println("-ERR Load : " + ex.getMessage());
                OurDialog.showErrorDialog("Không thể kết nối cơ sở dữ liệu\r\nBạn hãy khởi động lại chương trình. ");
                System.exit(0);
            }
        }
    }

    private void LoadConfig() {
        try {
            ServerInfo serInfo;
            serInfo = ClientXMLServerInfo.GetInfo();
            if (serInfo == null) {
                if (ClientXMLServerInfo.add(new ServerInfo("127.0.0.1", "8800")) == false) {
                    OurDialog.showErrorDialog("Không thể kết nối đến database");
                } else {
                    //tbIP.setText("127.0.0.1");
                    tbPort.setText("8800");
                }
            } else {
                //tbIP.setText(serInfo.GetIP());
                tbPort.setText(serInfo.GetPort());
            }
        } catch (Exception ex) {
            OurLogger.logError(this, "LoadConfig()", ex, Level.SEVERE);
        }
    }

private void btPatchFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPatchFolderActionPerformed
// chọn thư mục ảo
    final JFileChooser fc = new JFileChooser();
    JList list = new JList();
    fc.setDialogTitle("Chọn thư mục");
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (JFileChooser.APPROVE_OPTION == fc.showOpenDialog(list)) {
        File fFolder = fc.getSelectedFile();
        btPatchFolder.setToolTipText(fFolder.getPath());
        btPatchFolder.setText("Đổi thư mục");
        btPatchFolder.setForeground(new Color(0, 102, 0));
    }
}//GEN-LAST:event_btPatchFolderActionPerformed

private void btAddVirtualFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddVirtualFolderActionPerformed
// thêm thư mục ảo
    //@@@@@@@@ Không cho đặc tên thêm thư mục ảo "ErrorPage"
    try {
        if (!"".equals(btPatchFolder.getToolTipText())) {
            if (CheckNameVirtualFolder(tbVirtualName.getText())) {
                if (!ExistsNameVirtualFolder(tbVirtualName.getText(), -1)) {
                    VirtualDirectory vdVirFolder = new VirtualDirectory(tbVirtualName.getText(), btPatchFolder.getToolTipText());
                    if (XMLVirtualDirectory.add(vdVirFolder)) {
                        Vector rowData = new Vector();
                        rowData.add(tbVirtualName.getText());
                        rowData.add(btPatchFolder.getToolTipText());
                        rowData.add("    Tốt");
                        dtmVirtualFolder.addRow(rowData);

                        btPatchFolder.setToolTipText("");
                        btPatchFolder.setText("Chọn thư mục");
                        //btPatchFolder.setForeground(resourceMap.getColor("btPatchFolder.foreground"));
                        btPatchFolder.setForeground(Color.red);
                        tbVirtualName.setText("");
                        OurDialog.showInfoDialog("Thêm thành công.");
                    } else {
                        OurDialog.showErrorDialog("Thêm thất bại!!!\r\n\r\n"
                                + "Xin chú đọc yêu cầu \"Tên định danh\".\r\n\r\n"
                                + "   +  Không được để trống.\r\n" //+ "   +  Không được có ký tự khoảng trắng\r\n"
                                // + "   +  Không được có các ký tự sau: \r\n"
                                //+ "      ~ ` ! @ # $ % ^ & * ( ) _ + - = [ ]\r\n"
                                //+ "      { } | \\ ; : ' \" , . < > ? / "
                                );
                    }
                } else {
                    OurDialog.showInfoDialog("\"Tên định danh\" đã có, bạn hãy chọn tên khác.");
                }
            } else {
                OurDialog.showErrorDialog("Bạn nhập \"Tên định danh\" chưa đúng.\r\n\r\n"
                        + "   +  Không được để trống.\r\n" //+ "   +  Không được có ký tự khoảng trắng\r\n"
                        // + "   +  Không được có các ký tự sau: \r\n"
                        //+ "      ~ ` ! @ # $ % ^ & * ( ) _ + - = [ ]\r\n"
                        //+ "      { } | \\ ; : ' \" , . < > ? / "
                        );
            }
        } else {
            OurDialog.showInfoDialog("Bạn chưa \"Chọn thư mục\"");
        }
    } catch (IOException ex) {
        OurLogger.logError(this, "btAddVirtualFolderActionPerformed()", ex, Level.SEVERE);
        OurDialog.showErrorDialog("btAddVirtualFolderActionPerformed: " + ex.getMessage());
    } catch (JDOMException ex) {
        OurLogger.logError(this, "btAddVirtualFolderActionPerformed()", ex, Level.SEVERE);
        OurDialog.showErrorDialog("btAddVirtualFolderActionPerformed: " + ex.getMessage());
    }
}//GEN-LAST:event_btAddVirtualFolderActionPerformed
    private boolean CheckNameVirtualFolder(String sFolder) {
        //System.out.println(sFolder.indexOf("\t") + " sd");
        if ("".equals(sFolder))// || sFolder.indexOf(" ")>=0 /*|| sFolder.indexOf("\t")>=0 || sFolder.indexOf("\n")>=0*/)
        {
            return false;
        }
        return true;
    }

    private boolean ExistsNameVirtualFolder(String sFolder, int iRowSelected) {
        try {
            String[] sSplitName = sFolder.split("/");
            sFolder = sSplitName[0];
            for (int j = 1; j < sSplitName.length; j++) {
                if (!sSplitName[j].equals("")) {
                    sFolder = sFolder + "/" + sSplitName[j];
                }
            }
            if (sFolder.startsWith("/") && sFolder.length() > 1) {
                sFolder = sFolder.substring(1, sFolder.length());
            }



            if (sFolder.equals("ErrorPage"))//ErrorPage
            {
                return true;
            }

            for (int i = 0; i < dtmVirtualFolder.getRowCount(); i++) {
                if (dtmVirtualFolder.getValueAt(i, 0).equals(sFolder) && i != iRowSelected) {
                    return true;
                }
            }
            tbVirtualName.setText(sFolder);
            return false;
        } catch (Exception ex) {
            return true;
        }
    }

private void tblViewVirtualFoldersAncestorRemoved(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_tblViewVirtualFoldersAncestorRemoved
// xóa trên bảng danh sách thư mục ảo
    int i = 9;
    System.out.println("tblViewVirtualFoldersAncestorRemoved");
}//GEN-LAST:event_tblViewVirtualFoldersAncestorRemoved

private void tblViewVirtualFoldersMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblViewVirtualFoldersMouseClicked
// click chọn trên table
    try {

        System.out.println("tblViewVirtualFoldersMouseClicked ; R: " + tblViewVirtualFolders.getSelectedRow() + " __ C: " + tblViewVirtualFolders.getSelectedColumn());
        if (tblViewVirtualFolders.getSelectedColumn() == 1 && evt.getClickCount() == 2) {
            tAutoLoad.Stop();

            int iSelRow = tblViewVirtualFolders.getSelectedRow();
            int iSelCol = tblViewVirtualFolders.getSelectedColumn();

            final JFileChooser fc = new JFileChooser();
            JList list = new JList();
            fc.setDialogTitle("Chọn thư mục");
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            if (JFileChooser.APPROVE_OPTION == fc.showOpenDialog(list)) {
                File fFolder = fc.getSelectedFile();
                VirtualDirectory virFolder = new VirtualDirectory(dtmVirtualFolder.getValueAt(iSelRow, 0).toString(), fFolder.getPath());

                if (XMLVirtualDirectory.update(virFolder.getName(), virFolder)) {
                    dtmVirtualFolder.setValueAt(fFolder.getPath(), iSelRow, iSelCol);
                    dtmVirtualFolder.setValueAt("   Tốt", iSelRow, iSelCol + 1);
                    System.out.println(fFolder);
                } else {
                    OurDialog.showErrorDialog("Cập nhật thất bại");
                }
            }
            tAutoLoad.ReStart();
        }
        if (tblViewVirtualFolders.getSelectedColumn() == 0) {
            //tAutoLoad.Stop();
            //bEditName = true;
            sOldCellValue = dtmVirtualFolder.getValueAt(tblViewVirtualFolders.getSelectedRow(), 0).toString();
        }
    } catch (IOException ex) {
        tAutoLoad.ReStart();
        OurDialog.showErrorDialog("Không tìm thấy cơ sở dữ liệu");
        OurLogger.logError(this, "tblViewVirtualFoldersMouseClicked()", ex, Level.SEVERE);
    } catch (JDOMException ex) {
        tAutoLoad.ReStart();
        OurDialog.showErrorDialog("Không tìm thấy cơ sở dữ liệu");
        OurLogger.logError(this, "tblViewVirtualFoldersMouseClicked()", ex, Level.SEVERE);
    }
}//GEN-LAST:event_tblViewVirtualFoldersMouseClicked

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
// exit
    System.exit(0);
}//GEN-LAST:event_jMenuItem1ActionPerformed

private void tblViewVirtualFoldersKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblViewVirtualFoldersKeyPressed
// nhấn keyboard trên table
    //System.out.println("tblViewVirtualFoldersKeyPressed : " + evt.getKeyCode());
    if (evt.getKeyCode() == 127)//key code "Delete" = 127
    {
        if (OurDialog.showConfirmDialog("Bạn có muốn xóa những dòng đã chọn không?") == JOptionPane.YES_OPTION) {
            int iRowSelected = tblViewVirtualFolders.getSelectedRowCount();
            for (int i = 0; i < iRowSelected; i++) {
                int iRowSlect = tblViewVirtualFolders.getSelectedRows()[iRowSelected - i - 1];
                VirtualDirectory virFolder = new VirtualDirectory(dtmVirtualFolder.getValueAt(iRowSlect, 0).toString(), dtmVirtualFolder.getValueAt(iRowSlect, 1).toString());
                try {
                    if (XMLVirtualDirectory.delete(virFolder)) {
                        System.out.println("tblViewVirtualFoldersKeyPressed SelectedRow:" + tblViewVirtualFolders.getSelectedRows()[iRowSelected - i - 1]);
                        dtmVirtualFolder.removeRow(tblViewVirtualFolders.getSelectedRows()[iRowSelected - i - 1]);
                    } else {
                        OurDialog.showErrorDialog("Xóa \"" + dtmVirtualFolder.getValueAt(iRowSlect, 0).toString() + "\" thất bại!!!");
                        System.out.println("Không thể delete :" + dtmVirtualFolder.getValueAt(iRowSlect, 0).toString());
                    }
                } catch (IOException ex) {
                    OurLogger.logError(this, "tblViewVirtualFoldersKeyPressed()", ex, Level.SEVERE);
                    System.out.println("-ERR tblViewVirtualFoldersKeyPressed: " + ex.getMessage());
                } catch (JDOMException ex) {
                    OurLogger.logError(this, "tblViewVirtualFoldersKeyPressed()", ex, Level.SEVERE);
                    System.out.println("-ERR tblViewVirtualFoldersKeyPressed: " + ex.getMessage());
                }
            }
        }
    }
}//GEN-LAST:event_tblViewVirtualFoldersKeyPressed

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
// hướng dẫn sử dụng
    OurDialog.showInfoDialog("       __  HNV Web Server  __\r\n\r\n"
            + "HƯỚNG DẪN SỬ DỤNG:\r\n"
            + "   -  Thêm thư mục ảo:  Điền thông tin trong thẻ \"Tạo thư mục ảo\". Sau đó nhấn Thêm.\r\n"
            + "   -  Sửa thư mục ảo :   Nhấn double click vào ô dữ liệu cột \"Tên thư mục ảo\" hoặc \"Đường dẫn\".\r\n"
            + "   -  Xóa thư mục ảo :   Chọn những dòng cần xóa và nhấn phím Delete trên bàn phím.\r\n\r\n"
            + "   -  Thay đổi port :   Điền port mới vào phần \"Cài đặt\". Sau đó nhấn OK.\r\n\r\n"
            + "   -  Ẩn cửa sổ       :   Vào File chọn \"Tray me!\" hoặc double click vào tray icon.\r\n"
            + "   -  Hiện cửa sổ    :   Double click vào tray icon.\r\n\r\n"
            + "   *  Lưu ý               :   Tên thư mục ảo có phân biệt hoa thường.");
}//GEN-LAST:event_jMenuItem2ActionPerformed

private void miAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miAboutActionPerformed
// about
    OurDialog.showInfoDialog("       __  HNV Web Server  __\r\n"
            + "                version 1.0\r\n\r\n"
            + "Chương trình được thực hiện bởi nhóm sinh viên\r\n"
            + "Hùng, Nguyên, Vương lớp 10HCB\r\n"
            + "Trường ĐH Khoa Học Tự Nhiên TpHCM.");
}//GEN-LAST:event_miAboutActionPerformed

private void tblViewVirtualFoldersKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblViewVirtualFoldersKeyReleased
    System.out.println("tblViewVirtualFoldersKeyReleased");
}//GEN-LAST:event_tblViewVirtualFoldersKeyReleased

private void tblViewVirtualFoldersPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_tblViewVirtualFoldersPropertyChange
    try {
        if (evt.getOldValue() != null && evt.getNewValue() == null) {
            System.out.println("tblViewVirtualFoldersPropertyChange : update");
            int iRowSlect = tblViewVirtualFolders.getSelectedRows()[0];
            VirtualDirectory virFolder = new VirtualDirectory(dtmVirtualFolder.getValueAt(iRowSlect, 0).toString(), dtmVirtualFolder.getValueAt(iRowSlect, 1).toString());
            if (CheckNameVirtualFolder(virFolder.getName())) {
                if (!ExistsNameVirtualFolder(virFolder.getName(), iRowSlect)) {
                    dtmVirtualFolder.setValueAt(tbVirtualName.getText(), iRowSlect, 0);
                    virFolder.setName(tbVirtualName.getText());
                    tbVirtualName.setText("");
                    if (!XMLVirtualDirectory.update(sOldCellValue, virFolder)) {
                        Load();
                        System.out.println("Cập nhật thất bại");
                        OurDialog.showErrorDialog("Cập nhật thất bại!!!\r\n\r\n"
                                + "Xin chú đọc yêu cầu \"Tên định danh\".\r\n\r\n"
                                + "   +  Không được để trống.\r\n" //+ "   +  Không được có ký tự khoảng trắng\r\n"
                                // + "   +  Không được có các ký tự sau: \r\n"
                                //+ "      ~ ` ! @ # $ % ^ & * ( ) _ + - = [ ]\r\n"
                                //+ "      { } | \\ ; : ' \" , . < > ? / "
                                );
                    }
                } else {
                    OurDialog.showInfoDialog("\"Tên định danh\" đã có, bạn hãy chọn tên khác.");
                }
            } else {
                dtmVirtualFolder.setValueAt(sOldCellValue, iRowSlect, 0);
                OurDialog.showErrorDialog("Cập nhật thất bại!!!\r\n\r\n"
                        + "Xin chú đọc yêu cầu \"Tên định danh\".\r\n\r\n"
                        + "   +  Không được để trống.\r\n" //+ "   +  Không được có ký tự khoảng trắng\r\n"
                        // + "   +  Không được có các ký tự sau: \r\n"
                        //+ "      ~ ` ! @ # $ % ^ & * ( ) _ + - = [ ]\r\n"
                        //+ "      { } | \\ ; : ' \" , . < > ? / "
                        );
            }
        }

        bEditName = false;
        //tAutoLoad.Stop();
        //tAutoLoad.ReStart();
    } catch (Exception ex) {
        bEditName = false;
        //tAutoLoad.ReStart();
        Load();
        System.out.println("-ERR tblViewVirtualFoldersPropertyChange: " + ex.getMessage());
    }
}//GEN-LAST:event_tblViewVirtualFoldersPropertyChange

private void btChangConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btChangConfigActionPerformed
    try {
        int iPort = -1;
        try {
            iPort = Integer.parseInt(tbPort.getText());
        } catch (Exception ex) {
            OurDialog.showErrorDialog("Giá trị Port phải là số nguyên\r\nLớn hơn bằng 0 và nhỏ hơn bằng 2147483647\r\nMời bạn nhập lại.");
        }

        if (iPort >= 0) {
            if (ClientXMLServerInfo.update(new ServerInfo("127.0.0.1", tbPort.getText()))) {
                OurDialog.showInfoDialog("Cập nhật thành công");
                if (OurDialog.showConfirmDialog("Bạn có muốn chuyển qua port mới ngay bây giờ?") == OurDialog.YES) {
                    WebServer_GUIApp.stopListener();
                    WebServer_GUIApp.setAndStartListener(new Thread(new OurListener(iPort)));
                }
            } else {
                OurDialog.showErrorDialog("Cập nhật thất bại");
                LoadConfig();
            }
        } else {
            OurDialog.showErrorDialog("Giá trị Port phải là số nguyên\r\nLớn hơn bằng 0 và nhỏ hơn bằng 2147483647\r\nMời bạn nhập lại.");
        }
    } catch (Exception ex) {
        OurLogger.logError(this, "btChangConfigActionPerformed()", ex, Level.SEVERE);
    }

}//GEN-LAST:event_btChangConfigActionPerformed

private void tblViewVirtualFoldersMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblViewVirtualFoldersMouseExited
    System.out.println("tblViewVirtualFoldersMouseExited");
}//GEN-LAST:event_tblViewVirtualFoldersMouseExited

private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
    ((WebServer_GUIApp) getApplication()).toggleMainFrame();
}//GEN-LAST:event_jMenuItem3ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btAddVirtualFolder;
    private javax.swing.JButton btChangConfig;
    private javax.swing.JButton btPatchFolder;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JInternalFrame jInternalFrame2;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JLabel lbLogo;
    private javax.swing.JLabel lbTenDinhDanh;
    private javax.swing.JLabel lbTenDinhDanh2;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem miAbout;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JTextField tbPort;
    private javax.swing.JTextField tbVirtualName;
    private javax.swing.JTable tblViewVirtualFolders;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
}
